#include "QD3DResourcePack.h"
#include "QD3DUtils.h"

QD3DResourcePack::QD3DResourcePack (ID3D11Resource *pDxRes,
		UINT defaultCreateViews) : _pDxRes (pDxRes), _pDxSRV (NULL),
		_pDxUAV (NULL)
{
	QD3DUtils d3DUtils;
	if (defaultCreateViews & SRV)
		_pDxSRV = d3DUtils.createSRV (pDxRes);
	if (defaultCreateViews & UAV)
		_pDxUAV = d3DUtils.createUAV (pDxRes);
}


QD3DResourcePack::~QD3DResourcePack ()
{
	SAFE_RELEASE (_pDxSRV);
	SAFE_RELEASE (_pDxUAV);
	SAFE_RELEASE (_pDxRes);
}

ID3D11Resource * QD3DResourcePack::getRes ()
{
	return _pDxRes;
}

ID3D11ShaderResourceView * QD3DResourcePack::getSRV ()
{
	return _pDxSRV;
}

ID3D11UnorderedAccessView * QD3DResourcePack::getUAV ()
{
	return _pDxUAV;
}

void QD3DResourcePack::setSRV (ID3D11ShaderResourceView *pDxSRV)
{
	if (_pDxSRV) _pDxSRV->Release (); _pDxSRV = NULL;
	_pDxSRV = pDxSRV;
}

void QD3DResourcePack::setUAV (ID3D11UnorderedAccessView *pDxUAV)
{
	if (_pDxUAV) _pDxUAV->Release (); _pDxUAV = NULL;
	_pDxUAV = pDxUAV;
}
